package com.narunas.view
{
	import com.narunas.ApplicationFacade;
	import com.narunas.view.layout.resize.*;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class ResizerMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "resizer_mediator";
		
		public function ResizerMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
			
		}
		
		override public function getMediatorName():String
		{
			return NAME;
		}
		
		override public function getViewComponent():Object
		{
			return viewComponent;
		}
		
		override public function setViewComponent(viewComponent:Object):void
		{
		}
		
		override public function listNotificationInterests():Array
		{
			return [
				
				ApplicationFacade.ADD_TO_RESIZER,
				ApplicationFacade.FORCE_RESIZE,
				ApplicationFacade.REMOVE_FROM_RESIZE,
				ApplicationFacade.RESIZE_STAGE
				
			];
		}
		
		override public function handleNotification(n:INotification):void
		{
			switch(n.getName()){
				
				case ApplicationFacade.ADD_TO_RESIZER:
				
					var child:Object  	= n.getBody();	
					Resizer.getInstance().createRule(child as DisplayObject, child.ALIGNMENT, child.PARENT as DisplayObject, child.BOX, child.SCALE_WIDTH, child.SCALE_HEIGHT); 
					
				break;
				
				case ApplicationFacade.RESIZE_STAGE:
				break;
				
				case ApplicationFacade.FORCE_RESIZE:
				break;
				
				case ApplicationFacade.REMOVE_FROM_RESIZE:
				break;
				
			}
			//sendNotification(ApplicationFacade.FORCE_RESIZE);
			
		}
		
		override public function onRegister():void
		{
		}
		
		override public function onRemove():void
		{
		}
		
		
		/**
		 * 
		 *  PRIVATE FUNCTIONALITY
		 * **/
		 
		private function initializeResizer():void
		{
			
			//Resizer.getInstance().initialize(base, "TL", "noScale");
			
		} 
		 
		private function get base():Sprite {
			return MainApp(app).base;
		}
		
		private function get app():MainApp {
			return viewComponent as MainApp;
		}
	}
}